package com.blkbox.javaee.quartz.version2_0;

import org.quartz.CronScheduleBuilder;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

public class CronTriggerTest {

	public static void main(String[] args) throws SchedulerException {
		//0. Initiate a Schedule Factory
		SchedulerFactory schedulerFactory = new StdSchedulerFactory();
		Scheduler scheduler = schedulerFactory.getScheduler();
		//1. prepare job 
		JobDetail jobDetail=JobBuilder.newJob(SimpleQuartzJob.class).withIdentity("jobName-1", "jobNameGroup-1").build();
		//2. prepare trigger
		 Trigger cronTrigger=TriggerBuilder.newTrigger().withIdentity("cronTrigger-1", "cronTriggerGroup-1")  
	              .withSchedule(CronScheduleBuilder.cronSchedule("0/10 * * * * ?"))
	              .startNow().build();
		//3. start the scheduler
		scheduler.scheduleJob(jobDetail, cronTrigger);

		//4. start the scheduler
		scheduler.start();
	}

}
